package com.qyer.search.utils;

import org.apache.commons.collections4.CollectionUtils;

import java.util.*;

/**
 * Created by tangzheng on 16/3/10.
 */
public class ListUtils {
  public static <W> List<W> ToSubList(List<W> list, int from, int to){
    if(CollectionUtils.isEmpty(list))
      return (List<W>) (new ArrayList<W>());
      //return (List<W>)CollectionUtils.EMPTY_COLLECTION;
    /*if(from == to)
      return (List<W>) (new ArrayList<W>());*/
    if(list.size() < from)
      return new ArrayList<>();
    if(list.size() < to){
      return list.subList(from, list.size());
    }else {
      return list.subList(from, to);
    }
  }
}
